using Avanzis.QueryFramework;
using NUnit.Framework;

namespace Avanzis.QueryBuilder.Nunit
{
	/// <summary>
	/// Prueba del ConnectionStringBuilder
	/// </summary>
	[TestFixture]
	public class ConnectionStringBuilderTest
	{
        [TestFixtureSetUp]
        public void Setup()
        {
            QueryFrameworkConfiguration.Dialect = Dialects.MSSql2005Dialect;
            QueryBuilder.QueryProcessor.ResetProcessor();
        }

		public ConnectionStringBuilderTest()
		{
			
		}   

		[Test]
		public void TestConstructor()
		{
			ConnectionStringBuilder csb = new ConnectionStringBuilder("dbserver", "dbname", "sa", "mypasswordtest");
			Assert.AreEqual("dbserver", csb["server"]);
            Assert.AreEqual("dbserver", csb.Server);
			Assert.AreEqual("dbname", csb["database"]);
            Assert.AreEqual("dbname", csb.Database);
			Assert.AreEqual("sa", csb["user"]);
            Assert.AreEqual("sa", csb.User);
			Assert.AreEqual("mypasswordtest", csb["pwd"]);
            Assert.AreEqual("mypasswordtest", csb.Password);
			Assert.AreEqual("server=dbserver;database=dbname;user=sa;pwd=mypasswordtest", csb.ToString());

			csb = new ConnectionStringBuilder("server=dbserver;database=dbname;user=sa;pwd=mypasswordtest;");
			Assert.AreEqual("dbserver", csb["server"]);
			Assert.AreEqual("dbname", csb["database"]);            
			Assert.AreEqual("sa", csb["user"]);
			Assert.AreEqual("mypasswordtest", csb["pwd"]);
			Assert.AreEqual("server=dbserver;database=dbname;user=sa;pwd=mypasswordtest", csb.ToString());

			csb = new ConnectionStringBuilder();
			csb.Server = "dbserver";
			csb.Database = "dbname";
			csb.User = "sa";
			csb.Password = "mypasswordtest";			
			Assert.AreEqual("server=dbserver;database=dbname;user=sa;pwd=mypasswordtest", csb.ToString());
		}

		
	}
}
